//
//  UIView+XYFrame.m
//  NemoSDKDemo
//
//  Created by 高超 on 2020/7/28.
//  Copyright © 2020 JackYang. All rights reserved.
//

#import "UIView+XYFrame.h"

@implementation UIView (XYFrame)

- (CGPoint)xy_origin {
    return self.frame.origin;
}

- (void)setXy_origin:(CGPoint)xy_origin {
    CGRect frame = self.frame;
    frame.origin = xy_origin;
    self.frame = frame;
}

- (CGFloat)xy_x {
    return self.frame.origin.x;
}

- (void)setXy_x:(CGFloat)xy_x {
    CGRect frame = self.frame;
    frame.origin.x = xy_x;
    self.frame = frame;
}

- (CGFloat)xy_y {
    return self.frame.origin.y;
}

- (void)setXy_y:(CGFloat)xy_y {
    CGRect frame = self.frame;
    frame.origin.y = xy_y;
    self.frame = frame;
}

- (CGSize)xy_size {
    return self.bounds.size;
}

- (void)setXy_size:(CGSize)xy_size {
    CGRect frame = self.frame;
    frame.size = xy_size;
    self.frame = frame;
}

- (CGFloat)xy_width {
    return self.bounds.size.width;
}

- (void)setXy_width:(CGFloat)xy_width {
    CGRect frame = self.frame;
    frame.size.width = xy_width;
    self.frame = frame;
}

- (CGFloat)xy_height {
    return self.bounds.size.height;
}

- (void)setXy_height:(CGFloat)xy_height {
    CGRect frame = self.frame;
    frame.size.height = xy_height;
    self.frame = frame;
}

- (CGFloat)xy_right {
    return CGRectGetMaxX(self.frame);
}

- (void)setXy_right:(CGFloat)xy_right {
    CGRect frame = self.frame;
    frame.origin.x = xy_right - self.bounds.size.width;
    self.frame = frame;
}

- (CGFloat)xy_bottom {
    return CGRectGetMaxY(self.frame);
}

- (void)setXy_bottom:(CGFloat)xy_bottom {
    CGRect frame = self.frame;
    frame.origin.y = xy_bottom - self.bounds.size.height;
    self.frame = frame;
}

- (CGFloat)xy_centerX {
    return self.bounds.size.width * .5f;
}

- (void)setXy_centerX:(CGFloat)xy_centerX {
    CGPoint center = self.center;
    center.x = xy_centerX;
    self.center = center;
}

- (CGFloat)xy_centerY {
    return self.bounds.size.height * .5f;
}

- (void)setXy_centerY:(CGFloat)xy_centerY {
    CGPoint center = self.center;
    center.y = xy_centerY;
    self.center = center;
}

@end
